<?php
$id=isset($_GET['id'])?$_GET['id']:0;//难点：如何获取前一页点击ID是什么  解决方法：从地址栏传ID过来  获取  $_GET['地址栏参数的名称']
require 'dbcon.php';
$sql="delete from t_message where id={$id}";
$rs=$db->query($sql);//执行SQL语句
 if  ($rs==true)
 {
    echo "<script language='javascript' type='text/javascript'>"; 
    //echo "alert('留言成功！');";
    echo "window.location.href='index.php';";
    echo "</script>";
 }
 else {
    echo "<script language='javascript' type='text/javascript'>"; 
    echo "alert('删除失败！');";
    echo "window.location.href='index.php';";
    echo "</script>";
}

$db->close();

